package com.codeoss.module.res.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.codeoss.framework.service.impl.BaseTreeService;
import com.codeoss.module.res.dao.ResOrgMapper;
import com.codeoss.module.res.model.ResOrg;
import com.codeoss.module.res.service.IResOrgService;

@Service
public class ResOrgService extends BaseTreeService<ResOrgMapper, ResOrg> implements IResOrgService {

	@Override
	public List<ResOrg> getResOrgListByRoleIdList(List<Long> roleIdList) {
		// TODO Auto-generated method stub
		QueryWrapper<ResOrg> query=new QueryWrapper<ResOrg>();
		if(roleIdList.size()==0) {
			return new ArrayList<ResOrg>();
		}
		String ids="";
		for (int i = 0; i < roleIdList.size(); i++) {
			if(i>0) {
				ids+=",";
			}
			ids+=roleIdList.get(i);
		}
		query.inSql("id","(select res_org_id from res_rel_role_org where res_role_id in("+ids+"))");
		return list(query);
	}
}